import { GameLocalStorage, GlobleValue } from "../ComClass";

// Learn TypeScript:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class DebugUISc extends cc.Component {

    @property(cc.Label)
    gameSwitch: cc.Label = null;
    @property(cc.Label)
    ipSwitch: cc.Label = null;

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}


    update(dt) {
        this.gameSwitch.string = "审核状态：" + (GlobleValue.gameSwitch ? "开" : "关");
        this.ipSwitch.string = "IP限制：" + (GlobleValue.ipSwitch ? "开" : "关");
    }

    onclick_clear_save() {
        localStorage.clear();
        GameLocalStorage.Init();
        GameLocalStorage.Save();
    }
    onclick_gameswith() {
        GlobleValue.gameSwitch = !GlobleValue.gameSwitch;
    }
    onclick_ipswith() {
        GlobleValue.ipSwitch = !GlobleValue.ipSwitch;
    }
    onclick_add_gem() {
        GameLocalStorage.gameData.gem += 100;
    }

    onclick_close() {
        this.node.destroy();
    }
}
